[codex] Stabilize goal extraction batch tests#7891
Conversation
Greptile SummaryThis PR stabilizes the previously-failing
Confidence Score: 4/5Safe to merge. The changes are confined to a test file and the CI runner script; no production code is touched. The module-isolation machinery is well-reasoned and the 18 tests correctly verify the batched The restore coverage in Important Files Changed
Sequence DiagramsequenceDiagram
participant TF as test_goal_extraction_batch.py
participant SM as sys.modules
participant GM as utils.llm.goals
TF->>SM: snapshot saved_modules and saved_parent_attrs
TF->>SM: "install stubs for database.* utils.llm.clients utils.llm.usage_tracker"
TF->>GM: importlib.import_module
Note over GM: binds get_llm = stub, track_usage = stub, goals_db = stub
GM-->>TF: _goals_module reference saved
TF->>SM: _restore_stub_modules removes stubs and restores originals
loop each test
TF->>TF: reset_mocks resets get_user_goals and update_goal_progress
TF->>GM: patch.object goals_module.get_llm with MagicMock returning mock_llm
GM->>GM: extract_and_update_goal_progress calls goals_db.get_user_goals
GM->>GM: calls get_llm via patched mock_llm.invoke
GM-->>TF: result dict
end
|
6d936d4 to
e10308b
Compare
kodjima33
left a comment
There was a problem hiding this comment.
Test-only stabilization (import isolation / stubs); zero product risk, CI not failing.
Summary
test_goal_extraction_batch.pyto patch the currentget_llm('goals')path instead of the removedllm_minidependency.utils.llm.goalsbehind temporary dependency stubs, then restoresys.modulesand parent package attrs so collection does not pollute neighboring tests.test_goal_extraction_batch.pytobackend/test.shnow that it passes again.This complements #7890: that PR wires the other stable unit files into
backend/test.sh, while this PR fixes the previously failing goal extraction batch test before adding it.Validation
python -m pytest backend\\tests\\unit\\test_goal_extraction_batch.py -q --tb=short-> 18 passedpython -m pytest backend\\tests\\unit\\test_goal_extraction_batch.py backend\\tests\\unit\\test_listen_pipeline.py -q --tb=short-> 122 passedpython -m pytest backend\\tests\\unit\\test_goal_extraction_batch.py backend\\tests\\unit\\test_goals_id_fallback.py -q --tb=short-> 27 passedpython -m black --check --line-length 120 --skip-string-normalization backend\\tests\\unit\\test_goal_extraction_batch.pypython -m py_compile backend\\tests\\unit\\test_goal_extraction_batch.pygit diff --check origin/main..HEADgit diff --checkscripts/pre-commit